﻿using System;
using System.Web.Mvc;
using Common.Objects;
using Common.Objects.Enums;
using Common.WebApplication;
using EYCmsAdmin.Presentation.FilterAttributes;
using EYCmsAdmin.Presentation.IPresentationServices;
using EYCmsAdmin.Presentation.Models;
using EYCmsAdmin.Presentation.Models.LoginModels;

namespace EYCmsAdmin.Presentation.Controllers
{
    [Permission(Roles.Admin)]
    public class HomeController: Controller
    {
        private readonly IUserPresentationService userPresentationService;
        private readonly IStudyGroupPresentationService studyGroupPresentationService;

        public HomeController(IUserPresentationService userPresentationService, IStudyGroupPresentationService studyGroupPresentationService)
        {
            this.userPresentationService = userPresentationService;
            this.studyGroupPresentationService = studyGroupPresentationService;
        }

        [HttpGet]
        public ActionResult Index()
        {
            int userId = (BaseApplication.GetLoggedUser() as SystemUser).UserId;
            string sectionName = userPresentationService.GetUserHomeSection(userId);
            var group = studyGroupPresentationService.Get(3);
            return View(new HomeModel(sectionName));
        }
    }
}